[Bug]: NvmExpressDxe and NvmExpressPei are missing 'volatile' for pointer to struct located in memory updated by Nvme controller · Issue #324 · microsoft/mu

您所在的位置:网站首页 h97iplus NVMe DXE [Bug]: NvmExpressDxe and NvmExpressPei are missing 'volatile' for pointer to struct located in memory updated by Nvme controller · Issue #324 · microsoft/mu

[Bug]: NvmExpressDxe and NvmExpressPei are missing 'volatile' for pointer to struct located in memory updated by Nvme controller · Issue #324 · microsoft/mu

2023-03-22 13:11| 来源: 网络整理| 查看: 265

Is there an existing issue for this? I have searched existing issues Current Behavior

From NvmExpressDxe\NvmExpressPassthru.c, function NvmExpressPassThru:

while (EFI_ERROR (gBS->CheckEvent (TimerEvent))) { if (Cq->Pt != Private->Pt[QueueId]) { Status = EFI_SUCCESS; break; } }

Before this 'while' loop, the code has initiated an NVMe transaction via a submission queue. The 'while' loop is looking for a state change of 'Cq->Pt' indicating that the transaction is complete.

'Cq' is a pointer to 'NVME_CQ' which is a structure that is updated by the Nvme controller. This structure should have the 'volatile' keyword to ensure that the memory is re-read within the 'while' loop. Without 'volatile', the compiler is only reading the 'Cq->Pt' once outside of the 'while' loop and then doing register compares within the 'while' loop.

It has been observed (on AARCH64 target hardware) that in some cases, 'Cq->Pt' has not yet been updated by the NVMe controller by the time the code reaches the 'while' loop. In those cases, the 'while' loop will only terminate due to timeout because the external memory is no longer being read within the 'while' loop.

A similar code construct is in NvmExpressPei\NvmExpressPassThru.c and there may be other areas where 'volatile' is missing.

Expected Behavior

Using 'volatile' with declarations of pointer to NVME_CQ results in code that re-reads the memory within the 'while' loop ensuring that the updated state of 'Cq->Pt' is detected.

Steps To Reproduce

The problem is intermittent and may depend on underlying hardware and toolchain optimization flags.

Issue any commands/procedures to read from an NVMe drive. Observe NVMe command timeout errors through logs and addition of debug prints in NvmExpressPassThru.c. Code inspection and analysis of assembly listing of execution binaries with and without 'volatile' keyword.

Build Environment - OS(s): Windows 11 WSL2 - Tool Chain(s): GCC5 - Targets Impacted: ALL Version Information Release/202208 Urgency

Medium

Are you going to fix this?

Someone else needs to fix it

Do you need maintainer feedback?

Maintainer feedback requested

Anything else?

There may be other modules besides NvmExpressDei and NvmExpressPei that are missing the 'volatile' keyword.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3